package com.example.swagger.service;

import com.example.swagger.entity.Department;
import com.example.swagger.mapper.DepartmentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

@Service
@Component
public class DepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;
    public List<Department> getDepartments(){
        return departmentMapper.getDepartments();
    }

    public void addDepartment(Integer id,String departmentName){
        departmentMapper.insertDepartment(id, departmentName);
    }

    public Department getDepartment(Integer id){
        return departmentMapper.getDepartmentById(id);
    }

    public void deleteDepartment(Integer id){
        departmentMapper.deleteDepartmentById(id);
    }
}
